package com.ruoyi.puyu.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.puyu.domain.PuyuPointsRule;
import com.ruoyi.puyu.mapper.PuyuPointsRuleMapper;
import com.ruoyi.puyu.service.IPuyuPointsRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 积分规则Service业务层处理
 * 
 * @author wusongwen
 * @date 2024-12-25
 */
@Service
public class PuyuPointsRuleServiceImpl implements IPuyuPointsRuleService 
{
    @Autowired
    private PuyuPointsRuleMapper puyuPointsRuleMapper;

    /**
     * 查询积分规则
     * 
     * @param ruleId 积分规则主键
     * @return 积分规则
     */
    @Override
    public PuyuPointsRule selectPuyuPointsRuleByRuleId(Long ruleId)
    {
        return puyuPointsRuleMapper.selectPuyuPointsRuleByRuleId(ruleId);
    }

    @Override
    public PuyuPointsRule selectPuyuPointsRuleLatest() {
        return puyuPointsRuleMapper.selectPuyuPointsRuleLatest();
    }

    /**
     * 查询积分规则列表
     * 
     * @param puyuPointsRule 积分规则
     * @return 积分规则
     */
    @Override
    public List<PuyuPointsRule> selectPuyuPointsRuleList(PuyuPointsRule puyuPointsRule)
    {
        return puyuPointsRuleMapper.selectPuyuPointsRuleList(puyuPointsRule);
    }

    /**
     * 新增积分规则
     * 
     * @param puyuPointsRule 积分规则
     * @return 结果
     */
    @Override
    public int insertPuyuPointsRule(PuyuPointsRule puyuPointsRule)
    {
        puyuPointsRule.setCreateTime(DateUtils.getNowDate());
        return puyuPointsRuleMapper.insertPuyuPointsRule(puyuPointsRule);
    }

    /**
     * 修改积分规则
     * 
     * @param puyuPointsRule 积分规则
     * @return 结果
     */
    @Override
    public int updatePuyuPointsRule(PuyuPointsRule puyuPointsRule)
    {
        puyuPointsRule.setUpdateTime(DateUtils.getNowDate());
        return puyuPointsRuleMapper.updatePuyuPointsRule(puyuPointsRule);
    }

    /**
     * 批量删除积分规则
     * 
     * @param ruleIds 需要删除的积分规则主键
     * @return 结果
     */
    @Override
    public int deletePuyuPointsRuleByRuleIds(Long[] ruleIds)
    {
        return puyuPointsRuleMapper.deletePuyuPointsRuleByRuleIds(ruleIds);
    }

    /**
     * 删除积分规则信息
     * 
     * @param ruleId 积分规则主键
     * @return 结果
     */
    @Override
    public int deletePuyuPointsRuleByRuleId(Long ruleId)
    {
        return puyuPointsRuleMapper.deletePuyuPointsRuleByRuleId(ruleId);
    }
}
